package packageParser;

import java.util.List;

import packageHandler.PackageHandlerForClient;
import protocol.DataPackage;
import protocol.DataPackage.MessageType;
import frame.ChatFrame;


public class PackageParserForClient {
	
	//用户接收package包后的处理
	public static boolean packageParseClientReiceive(DataPackage pack, List<String> userList, ChatFrame chatRoom, String loginName){
		MessageType type = pack.getMessageType();
		
		//用户获得服务器传过来的 用户列表
		if(type == MessageType.LIST){
			PackageHandlerForClient.receiveLIST(pack, userList, chatRoom, loginName);
		}
		//用户接受到其他用户的信息
		else if (type == MessageType.MESSAGE){
			PackageHandlerForClient.receiveTEXT(pack, userList, chatRoom);
		}
		else if(type == MessageType.SHAKE){
			PackageHandlerForClient.receiveSHAKE(pack, userList, chatRoom);
		}
		else if(type == MessageType.LOGIN){
			PackageHandlerForClient.receiveLOGIN(pack, userList, chatRoom);
			
		}
		else if(type == MessageType.LOGOUT){
			return PackageHandlerForClient.receiveLOGOUT(pack, userList, chatRoom, loginName);
		}
		return true;
	}
}	
